﻿// 1.1.7.05. Write a program, which finds the maximal sequence of consecutively placed increasing integers.
// Example: {3, 2, 3, 4, 2, 2, 4} -> {2, 3, 4}.

using System;

class ContigueslyIncreasingElements
{
    static void Main()
    {
        int[] someArray = new int[] { 3, 2, 3, 4, 2, 2, 4 };
        int increasingElementsCounter = 1;
        int lastIncreasingElementValue = 0;
        int bestIncreasingElementsCounter = 1;
        int bestLastIncreasingElementValue = 0;

        for (int i = 1; i < someArray.Length; i++)
        {
            if (someArray[i] == (someArray[i - 1] + 1))
            {
                increasingElementsCounter++;
                lastIncreasingElementValue = someArray[i];
                if (increasingElementsCounter > bestIncreasingElementsCounter)
                {
                    bestIncreasingElementsCounter = increasingElementsCounter;
                    bestLastIncreasingElementValue = lastIncreasingElementValue;
                }
            }
            else
            {
                increasingElementsCounter = 1;
                lastIncreasingElementValue = 0;
            }
        }

        Console.Write("{");
        for (int i = 0; i < bestIncreasingElementsCounter; i++)
        {
            if (i != (bestIncreasingElementsCounter - 1))
            {
                Console.Write(((bestLastIncreasingElementValue - bestIncreasingElementsCounter + 1) + i) + ",");
            }
            else
            {
                Console.Write((bestLastIncreasingElementValue - bestIncreasingElementsCounter + 1) + i);
            }
        }
        Console.WriteLine("}");
    }
}